package com.szsh.aiot.hsm.config;

import org.influxdb.BatchOptions;
import org.influxdb.InfluxDB;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

@Configuration
public class InfluxDbCustomizer implements org.springframework.boot.autoconfigure.influx.InfluxDbCustomizer {

    @Value("${spring.influx.database}")
    private String database;

    @Value("${spring.influx.retentionPolicy}")
    private String retentionPolicy;

    @Override
    public void customize(InfluxDB influxDb) {
        influxDb.setDatabase(database);
        influxDb.setRetentionPolicy(retentionPolicy);
        influxDb.setLogLevel(InfluxDB.LogLevel.BASIC);

        // 开启influxdb批量保存
        influxDb.enableBatch(BatchOptions.DEFAULTS);
    }
}
